Skip to content

Conversation

@Gokul45-45
Copy link
Contributor

Description

This PR adds the Valid Parentheses algorithm implementation using Stack data structure.

Problem

Checks if a string containing parentheses (), brackets [], and braces {} is valid according to:

  • Open brackets must be closed by the same type
  • Open brackets must be closed in the correct order

Changes Made

  • Added ValidParentheses.java in stacks package
  • Added comprehensive unit tests in ValidParenthesesTest.java
  • Includes edge case handling (null, odd length, empty string)

Testing

  • All tests pass locally
  • Covers valid cases: (), ()[]{}, {[]}
  • Covers invalid cases: (], ([)], {{{

Closes #6724

@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2025

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.50%. Comparing base (e841d73) to head (335732e).

Files with missing lines Patch % Lines
...ava/com/thealgorithms/stacks/ValidParentheses.java 87.50% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7117      +/-   ##
============================================
- Coverage     78.50%   78.50%   -0.01%     
- Complexity     6752     6757       +5     
============================================
  Files           759      760       +1     
  Lines         22402    22418      +16     
  Branches       4400     4404       +4     
============================================
+ Hits          17587    17599      +12     
- Misses         4109     4111       +2     
- Partials        706      708       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Gokul45-45
Copy link
Contributor Author

@DenizAltunkapan
could u please check and review the changes ,i would appereciate a quick response
,thank you!!

@DenizAltunkapan DenizAltunkapan enabled auto-merge (squash) November 27, 2025 11:27
@DenizAltunkapan DenizAltunkapan merged commit d1ea306 into TheAlgorithms:master Nov 27, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Valid Parenthesis using Java

3 participants